home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 526-550 / disk_542 / chemnimate / cmtsource.lzh / gonio.c < prev    next >
Text File  |  1991-04-12  |  2KB  |  117 lines

  1. /****************************************************************
  2.  *        gonio.h                        *
  3.  *                                *
  4.  *    Sin (x,multiplication)        (see below)        *
  5.  *    Cos (x,multiplication)        (see below)        *
  6.  *                                *
  7.  *==============================================================*
  8.  *                                *
  9.  *name    date    Author    Comment                    *
  10.  *                                *
  11.  *gon1    24Mar91    KvGend    created it for a integer-compiler.    *
  12.  *                                *
  13.  *                                *
  14.  ****************************************************************/
  15.  
  16.  
  17. int sintabel[] =
  18. {
  19.    /* 0 : */ 0,
  20.    /* 1 : */ 6,
  21.    /* 2 : */ 12,
  22.    /* 3 : */ 19,
  23.    /* 4 : */ 24,
  24.    /* 5 : */ 30,
  25.    /* 6 : */ 36,
  26.    /* 7 : */ 41,
  27.    /* 8 : */ 45,
  28.    /* 9 : */ 49,
  29.    /* 10 : */ 53,
  30.    /* 11 : */ 56,
  31.    /* 12 : */ 59,
  32.    /* 13 : */ 61,
  33.    /* 14 : */ 63,
  34.    /* 15 : */ 64,
  35.    /* 16 : */ 64,
  36.    /* 17 : */ 64,
  37.    /* 18 : */ 63,
  38.    /* 19 : */ 61,
  39.    /* 20 : */ 59,
  40.    /* 21 : */ 56,
  41.    /* 22 : */ 53,
  42.    /* 23 : */ 49,
  43.    /* 24 : */ 45,
  44.    /* 25 : */ 41,
  45.    /* 26 : */ 36,
  46.    /* 27 : */ 30,
  47.    /* 28 : */ 24,
  48.    /* 29 : */ 19,
  49.    /* 30 : */ 12,
  50.    /* 31 : */ 6,
  51.    /* 32 : */ 0,
  52.    /* 33 : */ -6,
  53.    /* 34 : */ -12,
  54.    /* 35 : */ -19,
  55.    /* 36 : */ -24,
  56.    /* 37 : */ -30,
  57.    /* 38 : */ -36,
  58.    /* 39 : */ -41,
  59.    /* 40 : */ -45,
  60.    /* 41 : */ -49,
  61.    /* 42 : */ -53,
  62.    /* 43 : */ -56,
  63.    /* 44 : */ -59,
  64.    /* 45 : */ -61,
  65.    /* 46 : */ -63,
  66.    /* 47 : */ -64,
  67.    /* 48 : */ -64,
  68.    /* 49 : */ -64,
  69.    /* 50 : */ -63,
  70.    /* 51 : */ -61,
  71.    /* 52 : */ -59,
  72.    /* 53 : */ -56,
  73.    /* 54 : */ -53,
  74.    /* 55 : */ -49,
  75.    /* 56 : */ -45,
  76.    /* 57 : */ -41,
  77.    /* 58 : */ -36,
  78.    /* 59 : */ -30,
  79.    /* 60 : */ -24,
  80.    /* 61 : */ -19,
  81.    /* 62 : */ -12,
  82.    /* 63 : */ -6,
  83.    /* 64 : */ 0};        /* end-of sintabel[] */
  84.  
  85.  
  86.  
  87.  
  88.  
  89. /*    normal maths:
  90.  *        y= 25*sin(x)            x:[0,2¶>
  91.  *
  92.  *    my routine:
  93.  *        y= Sin(x,25)            x:[0,64>
  94.  */
  95.  
  96. int
  97. Sin (int in, int mult)
  98. {
  99.   return ((mult * sintabel[in &63]) >> 6);
  100. }
  101.  
  102. /* tough eh?
  103.  * easy:
  104.  *    take the modulo of in,(in is 0 up to and including 63)
  105.  *    then look it up in the sinetable (???)
  106.  *    multiply it with mult,
  107.  *    divide it by 64,
  108.  *     return it.
  109.  */
  110.  
  111.  
  112. int
  113. Cos (int in, int mult)
  114. {
  115.   return ((mult * sintabel[(in +16) &63]) >> 6);
  116. }
  117.